global _start
[section .text]
_start:
	mov eax, 0x2002
	int 0x90
	cmp eax, 0
	jne .parent

.child:
	; print a 'A'
	mov eax, 'A'
	int 0x90
	mov eax, '['
	int 0x90

	; receive
	mov eax, 0x3002
	mov ebx, 0xFFFF
	mov ecx, child_msg
	int 0x90

	; print msg->dat	
	mov dword eax, [child_msg+8]
	int 0x90

	mov eax, ']'
	int 0x90

	; send back
	inc dword [child_msg+8]
	mov eax, 0x3001
	mov ebx, [child_msg+4]
	mov ecx, child_msg
	int 0x90
	jmp .child

.parent:
	mov edx, eax
	mov dword [parent_msg+8], 'B'

.loop:
	; send
	mov eax, 0x3001
	mov ebx, edx		;pid
	mov ecx, parent_msg	;msg
	int 0x90

	; receive
	mov eax, 0x3002
	mov ebx, edx
	mov ecx, parent_msg
	int 0x90
	
	jmp .loop

child_msg:
	dd 12	;size
	dd 0	;pid
	dd 0	;char
parent_msg:
	dd 12	;size
	dd 0	;pid
	dd 0	;char

